package com.cdie.myschool.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import cn.hutool.core.date.DateUtil;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 乐跑信息表
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "enjoy_running_info")
public class EnjoyRunningInfo {
    /*主键*/
    @TableId(value = "running_id", type = IdType.INPUT)
    private long runningId;
    /*学年学期id*/
    @TableField(value = "semester_id")
    private long semesterId; //SELECT semester_id FROM calendar WHERE begin_time LIKE '2021%' and end_time LIKE '2022-01%' ;
    /*学号*/
    @TableField(value = "student_id")
    private Long studentId;
    /*开跑时间*/
    @TableField(value = "begin_time")
    private Date beginTime;
    /*运动距离*/
    @TableField(value = "moving_distance")
    private BigDecimal movingDistance;
    /*运动时长*/
    @TableField(value = "exercise_duration")
    private String exerciseDuration;
    /*结束时间*/
    @TableField(value = "end_time")
    private Date endTime;
    /*时间戳*/
    @TableField(value = "timestamp")
    private Date timeStamp;

    public EnjoyRunningInfo(EnjoyRunningInfoOld source) {
        this.runningId = Long.valueOf(source.getId());
        this.studentId = Long.valueOf(source.getXh());
        this.beginTime = DateUtil.parse(source.getTjsj());
        this.movingDistance = BigDecimal.valueOf(Double.parseDouble(source.getYdjl()));
        this.exerciseDuration = source.getTjsj();
        this.endTime = DateUtil.parse(source.getTjsj());
        this.timeStamp =DateUtil.parse(source.getTstamp(),"yyyyMMddHHmmss");
    }

}
